<?php

namespace Ycr\Pack\redis;

use Ycr\Pack\exception\HttpErrorException;

/**
 * Class BaseRedis
 * @package Ycr\Pack\redis
 * @author ycr <Email: yuncran@126.com>
 */
class BaseRedisConnect
{
    protected $_redis;
    protected $_redis_ip = '127.0.0.1'; //ip
    protected $_redis_port = 6379; //端口
    protected $_redis_db = 0; //数据库号
    protected $_hash_prefix = 'my_list_data'; //前缀名称

    public function __construct($ip = '', $port = '', $db = '', $hash_prefix = '')
    {
        if ($ip != '') $this->_redis_ip = $ip;
        if ($port != '') $this->_redis_port = $port;
        if ($db != '') $this->_redis_db = $db;
        if ($hash_prefix != '') $this->_hash_prefix = $hash_prefix;
        $this->_redis = new \Redis();
        $this->_redis->connect($this->_redis_ip, $this->_redis_port);
        $this->_redis->select($this->_redis_db);
    }

}